<template>
	<view class="warp">
		<view class="postBanner">
			<view class="car_box"></view>
		</view>
		<u--form :model="form" :rules="rules" ref="uForm" :errorType="errorType">
			<view class="class_box">
				<view class="title">回收品类</view>
				<view class="class_item">
					<view @click="typeDianji(item.type)" :class="item.type == type ? 'item_icon on' : 'item_icon'"
						v-for="(item, index) in classdate" :key="index">
						<u-image width="126rpx" height="126rpx" :src="item.img"></u-image>
						<view class="name">{{item.name}}</view>
					</view>
				</view>
			</view>
			<u-gap height="20" bg-color="#f5f5f5"></u-gap>
			<view class="class_box">
				<view class="title">今日指导价</view>
			</view>
			<u-cell-group>
				<u-cell title="黄纸" label="纯色纸箱,如家电包装箱" value="1元/公斤" :title-style="{color:'#000000',fontSize:'32rpx'}"
					:value-style="{color:'#009920',fontSize:'32rpx'}"></u-cell>
				<u-cell title="统纸" label="黄纸和花纸混合" value="1元/公斤" :title-style="{color:'#000000',fontSize:'32rpx'}"
					:value-style="{color:'#009920',fontSize:'32rpx'}"></u-cell>
			</u-cell-group>
			<u-gap height="20" bg-color="#f5f5f5"></u-gap>
			<view class="class_box">
				<view class="title">回收要求</view>
				<view class="husouyq">
					<view class="cvs">
						<view class="ws is_1"></view>
						<text>拒绝掺水</text>
					</view>
					<view class="cvs">
						<view class="ws is_2"></view>
						<text>拒绝掺杂</text>
					</view>
					<view class="cvs">
						<view class="ws is_3"></view>
						<text>不少于10KG</text>
					</view>
				</view>
			</view>
			<u-gap height="20" bg-color="#f5f5f5"></u-gap>
			<view class="contentBody">
				<u-form-item label="预估重量" label-width="150">
					<u-radio-group v-model="form.radio" placement="column">
						<u-radio  :customStyle="{marginBottom: '8px'}" :active-color="'#00b362'" v-for="(item, index) in yuguzl" :key="index"
							:name="item.name" :disabled="item.disabled">
							{{ item.name }}
						</u-radio>
					</u-radio-group>
				</u-form-item>
				<u-form-item label="回收物照片" prop="form.idcard" label-width="150">
					<u-upload width="150" height="150"></u-upload>
				</u-form-item>
				<view class="addorderBox">
					<text>如您有多种回收品类，可先点击添加物品品类。</text>
					<u-button type="warning" shape="circle" plain @click="addbuy">
						<u-icon name="plus" size="32" style="margin-right:10rpx;"></u-icon>
						添加物品品类
					</u-button>
				</view>

				<u-form-item label="预约时间" :rightIconStyle="{color:'#00b362', fontSize: '32rpx'}"
					rightIcon="calendar-fill" label-width="150" prop="form.yuyoutime">
					<date-time-picker @timeSelected="handleTimeSelected" />
				</u-form-item>
				<u-form-item label="预约地址" label-width="150">
					<u-input v-model="form.yuyoudizi" />
					<u-button slot="right" type="primary" @click="toAddressList">更换/编辑地址</u-button>
				</u-form-item>

				<view class="tips_warning">
					注意事项：
					<p>1、因回收成本原因，社区、写字楼、单元楼价格面议</p>
					<p>2、小于10公斤暂不保证上门回收</p>
					<p>3、重量超过100公斤，需拍照供回收员参考</p>
					<p>4、若无法获取报价，请重新打开手机定重新进入获取</p>
				</view>

			</view>
			<u-gap height="190" bg-color="#f5f5f5"></u-gap>
			<view class="addSite">
				<view class="agreement">

					<u-checkbox-group v-model="form.checkedItems" placement="column" @change="checkboxChange">
						<u-checkbox :customStyle="{marginBottom: '8px'}" v-for="(item, index) in checkboxList1"
							:key="index" :label="item.name" :name="item.name" :disabled="item.disabled">
						</u-checkbox>
					</u-checkbox-group>

				</view>
				<view class="buttonBox">
					<u-button @click="submit" type="primary" shape="circle">公益赠送</u-button>
					<u-button @click="submit" type="success" shape="circle">立即下单</u-button>
				</view>
			</view>

			<!-- <u-select v-model="showTime" mode="mutil-column" :list="selectlist" @confirm="timeBack"></u-select> -->
		</u--form>

		<view class="buyOrderBox" @click="buyorder" v-if="leftBuyBtn">
			<u-icon name="car-fill" color="#ffffff" size="50"></u-icon>
		</view>
		<u-popup :show="cartBottom" :customStyle="{'bottom':'180rpx'}" border-radius="30" mode="bottom" closeable='true'
			@close="close">
			<view class="cartListBox">
				<view class="title">
					<text>已添加项目</text>
					<view class="empty">
						<u-icon label="清空" name="trash-fill" size="18"></u-icon>

					</view>
				</view>
				<u-cell-group>
					<u-cell title="纸皮类" :title-style="{color:'#000000','font-size':'32rpx'}">
						<u-image width="60rpx" height="60rpx" slot="icon"
							:src="require('@/static/coolc/postorder_1.jpg')"></u-image>
						<view class="c_r_text" slot="right-icon">
							<view class="price">10-50公斤</view>
							<view class="delBtn">删除</view>
						</view>
					</u-cell>
					<u-cell title="衣物&其它" :title-style="{color:'#000000','font-size':'32rpx'}">
						<u-image width="60rpx" height="60rpx" slot="icon"
							:src="require('@/static/coolc/postorder_2.jpg')"></u-image>
						<view class="c_r_text" slot="right-icon">
							<view class="price">100公斤以上</view>
							<view class="delBtn">删除</view>
						</view>
					</u-cell>
					<u-cell title="金属类" :title-style="{color:'#000000','font-size':'32rpx'}">
						<u-image width="60rpx" height="60rpx" slot="icon"
							:src="require('@/static/coolc/postorder_3.jpg')"></u-image>
						<view class="c_r_text" slot="right-icon">
							<view class="price">50-100公斤</view>
							<view class="delBtn">删除</view>
						</view>
					</u-cell>
					<u-cell title="塑料类" :title-style="{color:'#000000','font-size':'32rpx'}">
						<u-image width="60rpx" height="60rpx" slot="icon"
							:src="require('@/static/coolc/postorder_4.jpg')"></u-image>
						<view class="c_r_text" slot="right-icon">
							<view class="price">1-5公斤</view>
							<view class="delBtn">删除</view>
						</view>
					</u-cell>
				</u-cell-group>
				<!-- <u-gap height="60" bg-color="#f5f5f5"></u-gap> -->
			</view>
		</u-popup>
	</view>
</template>

<script>
	import DateTimePicker from '@/components/DateTimePicker.vue'; // 记得根据你的目录结构来调整路径


	export default {
		components: {
			DateTimePicker
		},
		data() {
			return {
				checkboxValue1: [],
				// 基本案列数据
				checkboxList1: [{
						name: '勾选代表同意《收呗环保上门回收免责条款》',
						disabled: false
					}
				],
				form: {
					checkedItems: [],
					radio: null,
					yuyoutime: '',
					yuyoudizi: '',
					checkbox: false,
				},
				rules: {},
				yuguzl: [{
					name: "10-50公斤"
				}, {
					name: "50-100公斤"
				}, {
					name: "100公斤以上"
				}],
				classdate: [{
						img: require('@/static/coolc/postorder_1.jpg'),
						name: "纸皮类",
						type: "zp"
					},
					{
						img: require('@/static/coolc/postorder_2.jpg'),
						name: "衣物类",
						type: "yw"
					},
					{
						img: require('@/static/coolc/postorder_3.jpg'),
						name: "金属类",
						type: "js"
					},
					{
						img: require('@/static/coolc/postorder_4.jpg'),
						name: "塑料类",
						type: "sl"
					},
				],
				errorType: 'message',
				cartBottom: false,
				leftBuyBtn: true,
				selectlist: [],
				showTime: false
			};
		},
		methods: {
			close() {
				this.cartBottom = false
				// console.log('close');
			},
			submit() {
				this.$refs.uForm.validate((valid) => {
					if (valid) {
						// Form is valid, submit the data
						console.log("Form submitted:", this.form);
					} else {
						console.log("Form validation failed!");
					}
				});
			},
			addbuy() {
				// Logic to add more items to the cart
			},
			buyorder() {
				this.cartBottom = true;
			},
			timeBack(selected) {
				// Callback for time selection
				this.form.yuyoutime = selected;
				this.showTime = false;
			},
			actionTimeShow() {
				this.showTime = true;
			},
			toAddressList() {
				// Logic to get and update address
				// 添加新地址
				uni.navigateTo({
					url: '/pages/address/AddressList'
				});
			},
			typeDianji(type) {
				this.type = type;
			}
		}
	};
</script>

<style lang="scss" scoped>
	.cartListBox {
		width: 750rpx;

		.title {
			width: 630rpx;
			padding: 28rpx;
			justify-content: space-between;
			display: flex;
		}

		.c_r_text {
			width: 270rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.price {
				width: 250rpx;
				text-align: right;
				color: #00b362;
			}

			.delBtn {
				width: 120rpx;
				text-align: right;
				color: #ff0000;
			}
		}
	}

	.postBanner {
		width: 750rpx;
		height: 200rpx;
		background-image: url(~@/static/coolc/postorder.jpg);
		background-repeat: no-repeat;
		background-size: 100% 200rpx;
		overflow: hidden;
		position: relative;

		.car_box {
			width: 289rpx;
			height: 160rpx;
			background: url(~@/static/coolc/car.png) no-repeat;
			background-size: 100% auto;
			position: absolute;
			bottom: 0rpx;
			right: 15%;
			animation: move 1.667s linear infinite;
		}
	}

	.class_box {
		width: 750rpx;
		padding: 28rpx;

		.title {
			font-size: 32rpx;
		}

		.class_item {
			width: 694rpx;
			padding-top: 30rpx;
			justify-content: space-between;
			align-items: center;
			text-align: center;
			display: flex;

			.item_icon {
				width: 154rpx;
				border: 2px solid #ffffff;
				border-radius: 10rpx;
				overflow: hidden;

				.u-image {
					margin: 12rpx;
				}

				&.on {
					border: 2px solid #00b362;

					.name {
						color: #00b362;
					}
				}

				.name {
					width: 154rpx;
					font-size: 26rpx;
					height: 50rpx;
					display: flex;
					justify-content: space-around;
					text-align: center;
					color: #666666;
				}
			}
		}
	}

	.husouyq {
		width: 694rpx;
		justify-content: space-between;
		display: flex;

		.cvs {
			width: 33.33%;
			padding-top: 36rpx;

			text {
				width: 100%;
				text-align: center;
				padding-top: 10rpx;
				font-size: 26rpx;
				color: #666666;
				display: block;
			}

			.ws {
				width: 120rpx;
				height: 120rpx;
				background-repeat: no-repeat;
				background-size: 100% 100%;
				background-position: center;
				margin: 0 auto;

				&.is_1 {
					background-image: url(@/static/coolc/p_1.jpg);
				}

				&.is_2 {
					background-image: url(@/static/coolc/p_2.jpg);
				}

				&.is_3 {
					background-image: url(@/static/coolc/p_3.jpg);
				}
			}
		}
	}

	.addorderBox {
		padding: 28rpx 0;

		text {
			width: 100%;
			display: block;
			text-align: center;
			font-size: 28rpx;
			color: #666666;
			padding: 0 0 18rpx 0;
		}
	}

	.addSite {
		width: 750rpx;
		height: 180rpx;
		position: 0 28rpx;
		position: fixed;
		left: 0px;
		bottom: 0px;
		z-index: 10078;
		background: #ffffff;
		box-shadow: 0 0 5px #dedede;

		.buttonBox {
			width: 694rpx;
			margin: 0 auto;
			display: flex;
			justify-content: space-between;

			.u-btn {
				width: 335rpx;
			}
		}

		.agreement {
			width: 750rpx;
			text-align: center;
			margin: 20rpx 0 18rpx 0;

			.agreement-text {
				padding-left: 8rpx;
				font-size: 26rpx;
				color: $u-tips-color;

				text {
					color: #00b362;
				}
			}
		}
	}

	.buyOrderBox {
		width: 100rpx;
		height: 100rpx;
		background: linear-gradient(to right, #ffb43f, #ff8a00);
		border-radius: 120rpx;
		position: fixed;
		left: 28rpx;
		bottom: 204rpx;
		z-index: 99;
		box-shadow: 0 0 8px #cccccc;

		.u-icon {
			width: 100rpx;
			height: 100rpx;
			justify-content: space-around;
			display: flex;
			align-items: center;
		}
	}
</style>